﻿using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace apidocument.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            // ILog log = LogManager.GetLogger("test");
            //var task= Task.Run(() =>
            // {
            //     log.Error("a");
            //     Thread.CurrentThread.Join(1000);
            //     log.Error("b");
            //     Thread.CurrentThread.Join(1000);
            //     log.Error("c");
            // });

            //Task.WaitAll(task);
            //var taskList = new List<Task>();
            //for (int i = 0; i < 20; i++)
            //{
            //    taskList.Add(Task.Run(() => test()));
            //}
            //Task.WaitAll(taskList.ToArray());

            //User user = new User { id =1,name="ljh"};
            //User user =null;
            //var list = new List<string>();
            //list.AddIF(user.name, () => user?.name != null);

            ViewData["context"] = "asdfsadf";
            return View();
        }

        //public static void test()
        //{
        //    Thread.Sleep(1000);
        //}

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult TestHtml()
        {
            ViewBag.selList1 = new SelectList(new String[] { "aaaaaaaa", "bbbbbbbb", "cbbbbbbbbb" });
            return View();
            try
            {

            }
            catch (Exception)
            {
                throw;
            }
        }

        public ActionResult MvcHtmlHelper()
        {
            return View();
        }
        public ActionResult JQGridShow()
        {
            return View();
        }

        public ActionResult JQGridList()
        {
            return Json(new {a="LLL" });
        }

        public ActionResult TP()
        {
            return View();
        }
        public ActionResult PS()
        {
            return View();
        }
    }

    public class User
    {
        public int id { get; set; }
        public string name { get; set; }
    }
    public static class Class1
    {
        public static void AddIF<T>(this IList<T> list, T item, Func<bool> func)
        {
            if (list == null)
            {
                throw new ArgumentNullException("list");
            }
            if (func())
            {
                if (item == null)
                {
                    throw new ArgumentNullException("item");
                }
                list.Add(item);
            }
        }
    }
}